package pro2
import scala.collection.mutable.Map
object testMap {
  def main(args: Array[String]): Unit = {
    //    不可变映射
    val student = Map("001" -> "Tom", "002" -> "Jack", "003" -> "Lucy")
//    student.foreach(println)
    for(x<-student){
      println(x)
    }
//        println(student("001"))
//    println(student)
    //    可变映射
//        val student2 = Map("001" -> "Tom", "002" -> "Jack", "003" -> "Lucy")
//        student2("001") = "Jerry"
//        student2("004") = "Tony"
    //    student2 += ("005" -> "Marry")
//        println(student2)

    //    println(student.keys) //返回所有的键
    //    println(student.values) //返回所有的值
//    if (!student.isEmpty) {
//      println("student不为空")
//      println(student.isEmpty)

      //    println(student.keys)
      //    println(student.values)

//                println(student.isEmpty) //判断是否为空
//                println(student.contains(key = "001")) //判断是否存在指定的键
//                      println(student ++ student2) //合并，合并时会移除重复的key
//    }
  }

}


